﻿using SocketWeaver.FixedMath;

namespace SocketWeaver.FPhysics2D
{
    public struct FRaycastHit2D
    {
        static FRaycastHit2D _snull = new FRaycastHit2D { collider = null };
        public static FRaycastHit2D Null
        {
            get
            {
                return _snull;
            }
        }
        //
        // Summary:
        //     The centroid of the primitive used to perform the cast.
        public FVector2 centroid { get; internal set; }
        //
        // Summary:
        //     The point in world space where the ray hit the collider's surface.
        public FVector2 point { get; internal set; }
        //
        // Summary:
        //     The normal vector of the surface hit by the ray.
        public FVector2 normal { get; internal set; }
        //
        // Summary:
        //     The distance from the ray origin to the impact point.
        public FFloat distance { get; internal set; }
        //
        // Summary:
        //     Fraction of the distance along the ray that the hit occurred.
        public FFloat fraction { get; internal set; }
        //
        // Summary:
        //     The collider hit by the ray.
        public FCollider2D collider { get; internal set; }
        //
        // Summary:
        //     The Rigidbody2D attached to the object that was hit.
        public FRigidbody2D rigidbody { get; internal set; }
        //
        // Summary:
        //     The Transform of the object that was hit.
        public FTransform transform { get; internal set; }

        public static implicit operator bool(FRaycastHit2D hit)
        {
            return hit.collider != null;
        }
    }
}
